//
//  TMGHelpTableViewCell.m
//  TMGold
//
//  Created by Mac on 2017/12/11.
//  Copyright © 2017年 tangmu. All rights reserved.
//

#import "TMGGoldBootomTableViewCell.h"
@interface  TMGGoldBootomTableViewCell()
@property(nonatomic, strong) UIView                     *backGroundView;
@property(nonatomic, strong) STLabel                     *titleLable;


@end

@implementation TMGGoldBootomTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 135;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = [UIColor clearColor];
    
    
    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(15, 5, UIScreenWidth - 30, [TMGGoldBootomTableViewCell cellHeight] - 10)];
    whiteView.backgroundColor = [UIColor whiteColor];
    whiteView.layer.cornerRadius = 10;
    whiteView.clipsToBounds = YES;
    [self addSubview:whiteView];

    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(5, 15, whiteView.width/2 , 50)
                                                text:@"22.45%\n\n预计黄金收益率"
                                           textColor:TM_secendTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentCenter];
    self.titleLable.numberOfLines = 0;
    self.titleLable.centerX = whiteView.width/4;
    self.titleLable.attributedText = [self.titleLable.text st_convertAttributeStringWithKeyWord:@"22.45%" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:TM_orangeColor}];
    [whiteView addSubview:self.titleLable];
    
    self.subtitleLable = [[STLabel alloc] initWithFrame:CGRectMake(5, 15, whiteView.width/2 , 50)
                                                text:@"￥22.45\n\n再投"
                                           textColor:TM_secendTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentCenter];
    self.subtitleLable.numberOfLines = 0;
    self.subtitleLable.centerX = 3 * whiteView.width/4;
    self.subtitleLable.attributedText = [self.subtitleLable.text st_convertAttributeStringWithKeyWord:@"￥22.45" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:TM_orangeColor}];
    [whiteView addSubview:self.subtitleLable];
    
    [NSString lableAutoAdjustheightWithLabel:self.titleLable];
    [NSString lableAutoAdjustheightWithLabel:self.subtitleLable];
    self.timeLable = [[STLabel alloc] initWithFrame:CGRectMake(5, self.subtitleLable.bottom, whiteView.width/2 , 25)
                                                   text:@"2017年12月12日14:42:13"
                                              textColor:TM_secendTextColor
                                                   font:15
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentCenter];
    self.timeLable.right = whiteView.width - 15;
    self.timeLable.bottom = whiteView.height - 5;
    [whiteView addSubview:self.timeLable];
    
    
}
- (void)setModel:(TMGBuyGoldRecordModel *)model{
    _model = model;
    NSString * rate = [NSString stringWithFormat:@"%@%@",model.year_rate,@"%"];
    self.titleLable.text = [NSString stringWithFormat:@"%@\n\n预计黄金收益率",
                            rate];
    self.titleLable.attributedText = [self.titleLable.text st_convertAttributeStringWithKeyWord:rate attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:TM_orangeColor}];
    
    NSString * states;
    if (model.is_on.integerValue == 1) {
        states = @"在投";
    }else{
        states = @"到期";
    }
    NSString * money = [NSString stringWithFormat:@"%@%@",
                        model.goods_number,@"克"];
    self.subtitleLable.text = [NSString stringWithFormat:@"%@\n\n%@",money,states];
    self.subtitleLable.attributedText = [self.subtitleLable.text st_convertAttributeStringWithKeyWord:money attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:TM_orangeColor}];

    self.timeLable.text = [NSString stringWithFormat:@"有效期至%@",model.end];
}
@end


